﻿@{
    ViewBag.Title = "SectionSalaryRoster";
    Layout = "~/Views/Shared/_UserPage.cshtml";
}

<script type="text/javascript">
    $(function () {
        $('#ContractType').combobox({
            editable: false, panelHeight: "auto",
            valueField: "DictionaryName",
            textField: "DictionaryName",
            url: "/Dictionary/GetDictionaryByTypeTag?typeTag=ContractType",
            onLoadSuccess: function () {
                var data = $('#ContractType').combobox('getData');
                if (data.length > 0) {
                    $('#ContractType').combobox('select', data[0]["DictionaryName"]);
                }
            },
            onSelect: function (record) {
                var projectID = $("#ProjectID").combobox('getValue');
                initContract(projectID, record.DictionaryName);
            }
        });

        $("#ProjectID").combobox({
            editable: false, panelHeight: "auto",
            valueField: 'ID',
            textField: 'ProjectName',
            url: '/ProjectInfo/ProjectInfoListForFlow',
            onLoadSuccess: function () {
                var data = $("#ProjectID").combobox('getData');
                if (data.length > 0) {
                    $("#ProjectID").combobox('select', data[0]["ID"]);
                }
            },
            onSelect: function (record) {
                var contractType = $("#ContractType").combobox('getValue');
                initContract(record.ID, contractType);
            }
        });
    });
    
    function initContract(projectID, contractType) {
        $("#ContractID").combobox({
            editable: false, panelHeight: "auto",
            valueField: 'ID',
            textField: 'ContractName',
            url: '/ContractInfo/ContractInfoListByProjectIDAndType?projectID=' + projectID + '&contractType=' + encodeURI(contractType),
            onLoadSuccess: function () {
                var data = $("#ContractID").combobox('getData');
                if (data.length > 0) {
                    $("#ContractID").combobox('select', data[0]["ID"]);
                }
            }
        });
    }

    function initTable() {
        var projectID = $("#ProjectID").combobox('getValue');
        var contractType = $("#ContractType").combobox('getValue');
        var contractID = $("#ContractID").combobox('getValue');

        $('#summaryDataGrid').datagrid({
            url: '/SectionSalary/GetSectionSalaryDetailListForRoster?projectID=' + projectID + '&contractType=' + contractType + '&contractID=' + contractID,
            iconCls: 'icon-bricks',
            nowrap: true,//当数据长度超出列宽时将会自动截取
            autoRowHeight: false,
            striped: true,//设置为true将交替显示行背景
            collapsible: true,
            remoteSort: false,
            idField: 'ID',//表明该列是一个唯一列。
            singleSelect: true,
            fitColumns: true,
            columns:
            [[
                { title: '身份证', field: 'CertificateNo', align: 'center', width: 100 },
                { title: '姓名', field: 'Name', align: 'center', width: 100 },
                { title: '性别', field: 'Sex', align: 'center', width: 50 },
                { title: '年龄', field: 'Age', align: 'center', width: 50 },
                { title: '工种', field: 'WorkType', align: 'center', width: 200 },
                { title: '累计工资发放', field: 'MonthSalary', align: 'center', width: 100 }
            ]],
            onLoadSuccess: function (data) {
                if (data.rows.length > 1) {
                    mergeCellsByField("summaryDataGrid", "CertificateNo");
                }
            }
        });
    }
</script>

<div class="easyui-layout" fit="true">
    <div data-options="region:'north'" style="height:35px;">
        <table style="margin-top: 5px">
            <tr>
                <td style="width: 95px; text-align: center">项目名称</td>
                <td>
                    <input id="ProjectID" name="ProjectID" class="easyui-combobox" style="width: 180px;" />
                </td>
                <td style="width: 95px; text-align: center">合同类型</td>
                <td>
                    <input id="ContractType" name="ContractType" class="easyui-combobox" style="width: 180px;" />
                </td>
                <td style="width: 95px; text-align: center">标段名称</td>
                <td>
                    <input id="ContractID" name="ContractID" class="easyui-combobox" style="width: 180px;" />
                </td>
                <td>
                    <a href="#" id="btnSearch" class="easyui-linkbutton" data-options="plain:true" onclick="initTable();">查看</a>
                </td>
            </tr>
        </table>
    </div>

    <div data-options="region:'center'">
        <table id="summaryDataGrid" fit="true"></table>
    </div>
</div>
